/*
 *  Copyright (c) 2023-2025 苏州棱镜七彩信息科技有限公司 (Suzhou PrismAurora Information Technology Co.,Ltd)
 *  sbom-generate is licensed under Mulan PSL v2.
 *  You can use this software according to the terms and conditions of the Mulan PSL v2.
 *  You may obtain a copy of Mulan PSL v2 at:
 *           http://license.coscl.org.cn/MulanPSL2
 *  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 *  See the Mulan PSL v2 for more details.
 * */
package com.ljqc.parameter;

import com.beust.jcommander.DynamicParameter;
import com.beust.jcommander.Parameter;
import com.ljqc.abs.sbom.SBom;
import com.ljqc.parameter.converter.FileConverter;
import com.ljqc.parameter.converter.LogConverter;
import com.ljqc.parameter.converter.SBomTypeConverter;
import com.ljqc.parameter.validator.HostValidator;
import com.ljqc.parameter.validator.LogValidator;
import com.ljqc.parameter.validator.OutValidator;
import com.ljqc.parameter.validator.RootValidator;
import com.ljqc.parameter.validator.SBomValidator;
import lombok.Data;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

/**
 * @ClassName SBomParameter
 * @Description 入参
 * @Date 2025/3/12 15:04
 * @Version V1.0
 **/
@Data
public class SBomParameter {

    @Parameter(names = {"-d", "--dir"}, description = "提取sbom清单的根目录", converter = FileConverter.class, validateWith = RootValidator.class, required = true)
    private File root;
    @Parameter(names = {"-t", "--type"}, description = "生成sbom的格式，默认值为SPDX_TAG_VALUE，可选值有：SPDX_TAG_VALUE,SPDX_JSON,CYCLONE_DX_JSON,CYCLONE_DX_XML,SWID_XML", converter = SBomTypeConverter.class, validateWith = SBomValidator.class)
    private SBom type = SBom.SPDX_TAG_VALUE;
    @Parameter(names = {"-o", "--out"}, description = "输出到具体目录或文件，默认输出到控制台", converter = FileConverter.class, validateWith = OutValidator.class)
    private File out;
    @Parameter(names = {"--host"}, description = "许可证关联openapi地址", validateWith = HostValidator.class)
    private String host;
    @Parameter(names = {"-n", "--name"}, description = "SBOM文档名称，如果不指定则使用UUID")
    private String documentName;
    @Parameter(names = {"-u", "--user"}, description = "SBOM文档创建者，如果不指定默认为NONE")
    private String user;
    @Parameter(names = {"-g", "--group"}, description = "SBOM文档创建者组织，如果不指定默认为NONE")
    private String userGroup;
    @Parameter(names = {"-l", "--log"}, description = "日志打印等级，默认INFO，可选值有：INFO,DEBUG,WARN,ERROR", converter = LogConverter.class, validateWith = LogValidator.class)
    private Level log = Level.INFO;
    @Parameter(names = "--help", help = true)
    private boolean help;
    @DynamicParameter(names = "-D", description = "动态参数，用于没有配置包管理器命令环境变量，或需要指定另外的包管理器命令具体路径的时候使用；格式：-D[包管理器命令]=[绝对路径] -D[包管理器命令]=[绝对路径]；示例：-Dmvn=/usr/local/bin/ -Dnpm=/usr/local/bin/")
    private Map<String, String> params = new HashMap<>();
}
